﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CuitWinRow.cs" company="">
//   
// </copyright>
// <summary>
//   The cuit win row.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.CUIT.CuitControls.WinControls
{
    using System.Collections.Generic;

    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    /// <summary>
    ///     The cuit win row.
    /// </summary>
    public class CuitWinRow : CuitWinControl<WinRow>
    {
        #region Constructors and Destructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="CuitWinRow" /> class.
        /// </summary>
        public CuitWinRow()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinRow"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        public CuitWinRow(UITestControl testControl)
            : base(testControl)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinRow"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitWinRow(UITestControl testControl, string searchProperties)
            : base(testControl, searchProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinRow"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitWinRow(UITestControl testControl, string searchProperties, string filterProperties)
            : base(testControl, searchProperties, filterProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinRow"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitWinRow(ICuitControlBase wrappedControl, string searchProperties)
            : base(wrappedControl, searchProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitWinRow"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitWinRow(ICuitControlBase wrappedControl, string searchProperties, string filterProperties)
            : base(wrappedControl, searchProperties, filterProperties)
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets the cells.
        /// </summary>
        public UITestControlCollection Cells
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.Cells;
            }
        }

        /// <summary>
        ///     Gets the cells as cui te.
        /// </summary>
        public List<CuitWinCell> CellsAsCUITe
        {
            get
            {
                var list = new List<CuitWinCell>();
                foreach (WinCell control in this._control.Cells)
                {
                    var cell = new CuitWinCell();
                    cell.WrapReady(control);
                    list.Add(cell);
                }

                return list;
            }
        }

        /// <summary>
        ///     Gets a value indicating whether selected.
        /// </summary>
        public bool IsSelected
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.Selected;
            }
        }

        /// <summary>
        ///     Gets the row index.
        /// </summary>
        public int RowIndex
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.RowIndex;
            }
        }

        /// <summary>
        ///     Gets the value.
        /// </summary>
        public string Value
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.Value;
            }
        }

        #endregion
    }
}